import mysql.connector
import openpyxl

# 建立数据库连接
# conn = mysql.connector.connect(
#     host="10.100.1.93",
#     user="ylsk_app",
#     password="dYPuqggg7CLmBIHICE",
#     database="wyc_db",
# )

conn = mysql.connector.connect(
    host="127.0.0.1",
    user="root",
    password="root",
    database="wyc_db",
)

cursor = conn.cursor()


# 读取Excel
wb = openpyxl.load_workbook("D://work//ylsk//export//药房白名单申请20251013.xlsx")
sheet = wb.active

# 跳过表头，逐行插入
for row in sheet.iter_rows(min_row=2, values_only=True):
    sql = "INSERT INTO wyc_db.tb_cust_label_temp(cust_name,cust_label) VALUES (%s, %s)"
    # data = (row[0],row[1])
    # cursor.execute(sql, data)
    print(row[0],row[1])
    cursor.execute(sql, row)

conn.commit()
cursor.close()
conn.close()
